﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IApi.cs" company="Spenta Consulting">
//   (c) Copyright 2011
// </copyright>
// <summary>
//   Interface for StreetCare Api Service
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Spenta.StreetCare.MVC.Services.Interfaces
{
    #region Using directives

    using System.Collections.Generic;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using Core.Models;
    using Data;

    #endregion

    #region Service Interface

    /// <summary>
    /// Interface for StreetCare Api Service
    /// </summary>
    [ServiceContract]
    public interface IApi
    {
        /// <summary>
        /// Gets the connected user identity.
        /// </summary>
        /// <returns>A user identity</returns>
        [OperationContract]
        GetUserIdentityResponse GetUserIdentity();

        /// <summary>
        /// Gets a user by its identity provider and its name identifier
        /// </summary>
        /// <param name="identityProvider">The identity provider.</param>
        /// <param name="nameIdentifier">The name identifier</param>
        /// <returns>The identity</returns>
        [OperationContract]
        GetUserByProviderAndIdentificatorResponse GetUserByProviderAndIdentificator(
            string identityProvider, string nameIdentifier);

        /// <summary>
        /// Gets a customer by its hostname.
        /// </summary>
        /// <param name="hostname">The hostname.</param>
        /// <returns>The customer</returns>
        [OperationContract]
        GetCustomerByHostnameResponse GetCustomerByHostname(string hostname);

        /// <summary>
        /// Gets a list of a customer categories.
        /// </summary>
        /// <param name="customerID">The customerID.</param>
        /// <returns>The categories list</returns>
        [OperationContract]
        GetCategoriesResponse GetCategories(int customerID);

        /// <summary>
        /// Gets a list of a customer categories with its associated reports count
        /// </summary>
        /// <param name="customerID">The customerID.</param>
        /// <returns>The list of categories</returns>
        [OperationContract]
        GetCategoriesWithCountResponse GetCategoriesWithCount(int customerID);

        /// <summary>
        /// Gets a list of customer statuses.
        /// </summary>
        /// <param name="customerID">The customerID.</param>
        /// <returns>The list of statuses</returns>
        [OperationContract]
        GetStatusesResponse GetStatuses(int customerID);

        /// <summary>
        /// Gets a list of customer statuses with its associated reports count
        /// </summary>
        /// <param name="customerID">The customerID.</param>
        /// <returns>The list of statuses</returns>
        [OperationContract]
        GetStatusesWithCountResponse GetStatusesWithCount(int customerID);

        /// <summary>
        /// Creates a new report with the given information
        /// </summary>
        /// <param name="report">The report information</param>
        /// <returns>The operation result</returns>
        [OperationContract]
        CreateReportResponse CreateReport(Report report);

        /// <summary>
        /// Gets the list of customer reports with the first available status.
        /// </summary>
        /// <param name="customerID">The customerID.</param>
        /// <returns>The list of reports</returns>
        [OperationContract]
        GetReportsResponse GetReports(int customerID);

        /// <summary>
        /// Gets the list of reports with the given status
        /// </summary>
        /// <param name="statusID">The status code.</param>
        /// <returns>The list of reports</returns>
        [OperationContract]
        GetReportsByStatusResponse GetReportsByStatus(int statusID);

        /// <summary>
        /// Gets the list of reports with the given category
        /// </summary>
        /// <param name="categoryID">The category code.</param>
        /// <returns>The list of reports</returns>
        [OperationContract]
        GetReportsByCategoryResponse GetReportsByCategory(int categoryID);

        /// <summary>
        /// Updates a report's status
        /// </summary>
        /// <param name="reportID">The report id</param>
        /// <param name="newStatusId">The new status id</param>
        /// <param name="newImageUrl">The new image url</param>
        /// <returns>The operation result</returns>
        [OperationContract]
        UpdateReportStatusResponse UpdateReportStatus(int reportID, int newStatusId, string newImageUrl);

        /// <summary>
        /// Gets the customer by its identificator
        /// </summary>
        /// <param name="customerID">The customer identificator</param>
        /// <returns>The customer</returns>
        [OperationContract]
        GetCustomerByIDResponse GetCustomerByID(int customerID);

        /// <summary>
        /// Gets the latest comments associated to a customer
        /// </summary>
        /// <param name="customerID">The customer identificator.</param>
        /// <returns>The list of comments</returns>
        [OperationContract]
        GetLatestCommentsResponse GetLatestComments(int customerID);

        /// <summary>
        /// Creates a comment.
        /// </summary>
        /// <param name="comment">The comment.</param>
        /// <returns>The operation result</returns>
        [OperationContract]
        CreateCommentResponse CreateComment(Comment comment);
    }

    #endregion

    #region Service Responses

    /// <summary>
    /// Response for GetUserIdentity method
    /// </summary>
    [DataContract]
    public class GetUserIdentityResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the User.
        /// </summary>
        /// <value>The User member.</value>
        [DataMember]
        public User User { get; set; }
    }

    /// <summary>
    /// Response for GetUserByProviderAndIdentificator method
    /// </summary>
    [DataContract]
    public class GetUserByProviderAndIdentificatorResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the User.
        /// </summary>
        /// <value>The User member.</value>
        [DataMember]
        public User User { get; set; }
    }

    /// <summary>
    /// Response for GetCustomerByHostname method
    /// </summary>
    [DataContract]
    public class GetCustomerByHostnameResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the Customer.
        /// </summary>
        /// <value>The Customer.</value>
        [DataMember]
        public Customer Customer { get; set; }
    }

    /// <summary>
    /// Response for GetCategories method
    /// </summary>
    [DataContract]
    public class GetCategoriesResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the categories.
        /// </summary>
        /// <value>The categories.</value>
        [DataMember]
        public List<Category> Categories { get; set; }
    }

    /// <summary>
    /// Response for GetCategoriesWithCount method
    /// </summary>
    [DataContract]
    public class GetCategoriesWithCountResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the categories with count.
        /// </summary>
        /// <value>The categories with count.</value>
        [DataMember]
        public List<CategoryWithCount> CategoriesWithCount { get; set; }
    }

    /// <summary>
    /// Response for GetStatusesWithCount method
    /// </summary>
    [DataContract]
    public class GetStatusesWithCountResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the statuses and the amount of reports related to each one.
        /// </summary>
        /// <value>The statuses with count.</value>
        [DataMember]
        public List<StatusWithCount> StatusesWithCount { get; set; }
    }

    /// <summary>
    /// Response for GetStatuses method
    /// </summary>
    [DataContract]
    public class GetStatusesResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the statuses.
        /// </summary>
        /// <value>The statuses.</value>
        [DataMember]
        public List<Status> Statuses { get; set; }
    }

    /// <summary>
    /// Response for CreateReport method
    /// </summary>
    [DataContract]
    public class CreateReportResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the report.
        /// </summary>
        /// <value>The report.</value>
        [DataMember]
        public Report Report { get; set; }
    }

    /// <summary>
    /// Response for GetReports methods
    /// </summary>
    [DataContract]
    public class GetReportsResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the reports.
        /// </summary>
        /// <value>The reports.</value>
        [DataMember]
        public List<Report> Reports { get; set; }
    }

    /// <summary>
    /// Response for GetReportsByStatus methods
    /// </summary>
    [DataContract]
    public class GetReportsByStatusResponse : GetReportsResponse
    {
    }

    /// <summary>
    /// Response for GetReportsByCategory methods
    /// </summary>
    [DataContract]
    public class GetReportsByCategoryResponse : GetReportsResponse
    {
    }

    /// <summary>
    /// Response for UpdateReportStatus methods
    /// </summary>
    [DataContract]
    public class UpdateReportStatusResponse : ServiceResponse
    {
    }

    /// <summary>
    /// Response for GetCustomerByID methods
    /// </summary>
    [DataContract]
    public class GetCustomerByIDResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the customer.
        /// </summary>
        /// <value>The customer.</value>
        [DataMember]
        public Customer Customer { get; set; }
    }

    /// <summary>
    /// Response for GetLatestComments methods
    /// </summary>
    [DataContract]
    public class GetLatestCommentsResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the comments.
        /// </summary>
        /// <value>The comments.</value>
        [DataMember]
        public List<Comment> Comments { get; set; }
    }

    /// <summary>
    /// Response for CreateComment methods
    /// </summary>
    [DataContract]
    public class CreateCommentResponse : ServiceResponse
    {
        /// <summary>
        /// Gets or sets the comment.
        /// </summary>
        /// <value>The comment.</value>
        [DataMember]
        public Comment Comment { get; set; }
    }

    #endregion
}